﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236

namespace pdftron.PDF.Tools.Controls
{
    /// <summary>
    /// The AnnotationToolbar works with a ToolManager to allow quick selection of different tools.
    /// The toolbar shows a list of buttons which prompts the associated ToolManager to switch to that tool.
    /// </summary>
    public sealed partial class AnnotationToolbar : pdftron.PDF.Tools.Controls.AnnotationToolbarBase
    {
        /// <summary>
        /// Creates a new AnnotationToolbar that is not associated with a ToolManager.
        /// Use the ToolManager property to make the AnnotationToolbar Work with a ToolManager.
        /// </summary>
        public AnnotationToolbar()
        {
            this.InitializeComponent();
            Init();
        }

        /// <summary>
        /// Creates a new AnnotationToolbar that works with the ToolManager.
        /// </summary>
        /// <param name="ctrl"></param>
        /// <param name="toolManager"></param>
        public AnnotationToolbar(ToolManager toolManager)
        {
            this.InitializeComponent();
            this.ToolManager = toolManager;
            Init();
        }

        private void Init()
        {

            MINIMUM_BUTTON_WIDTH = (double)this.Resources["AnnotationButtonWidth"];

            ToolbarButtonRanking = new ButtonBase[ToolbarButtonMainStack.Children.Count];

            int index = 0;

            // Highest priority: Will always be displayed
            ToolbarButtonRanking[index++] = ToolbarCloseButton;
            ToolbarButtonRanking[index++] = AnnotPanButton;
            ToolbarButtonRanking[index++] = AnnotStickyNoteButton;
            ToolbarButtonRanking[index++] = AnnotHighlightButton;
            ToolbarButtonRanking[index++] = AnnotFreeHandButton;
            ToolbarButtonRanking[index++] = AnnotEraserButton;
            ToolbarButtonRanking[index++] = AnnotSignatureButton;
            ToolbarButtonRanking[index++] = AnnotStrikeoutButton;
            ToolbarButtonRanking[index++] = AnnotUnderlineButton;
            ToolbarButtonRanking[index++] = AnnotFreeTextButton;
            ToolbarButtonRanking[index++] = AnnotArrowButton;
            ToolbarButtonRanking[index++] = AnnotSquareButton;
            ToolbarButtonRanking[index++] = AnnotCircleButton;
            ToolbarButtonRanking[index++] = AnnotLineButton;
            ToolbarButtonRanking[index++] = AnnotSquigglyButton;
        }
    }
}
